//=== 引用类型之间判断是否是同一个东西

//lazy load

class mapClass {
    var filename = "yoo"
}


class charClass {
    lazy var rareMap = mapClass()
    var online = true
}


//lazy 属性默认是nil
let character = charClass()
character.rareMap
character


//——————————————————————



//定义结构体，一般没办法修改结构| mutating -> 变异,通过变异可以修改值

struct armor {
    var bulletNum = 0
    var name = ""
    mutating func strValue(loc:Int){
        self.bulletNum = loc
    }
}

//定义类

class characterHum {
    var weapon = armor()
    var HP = 0
    var name = ""
    
//    !!! 如果是声明计算属性，需要明确定义属性的类型
    var hunt:Int{
        //需要处理get和set方法
        get{
            let hunt = 20
            return hunt
        }
        set{
            self.hunt = 2*HP
        }
    }
    //同样是计算属性，直接返回数值
    
    var maximum :Int{
        return self.hunt+self.HP
    }
}

let laser = armor(bulletNum: 90, name: "shootgun")
let gandom = characterHum()

gandom.weapon = laser

gandom.HP = 100

gandom.name = "ganda"
gandom.hunt

gandom.hunt=2
//gandom.maximum
gandom










































